// components/worker-search/worker-search.js
Component({
    options: {
        addGlobalClass: true
    },
    /**
     * 组件的属性列表
     */
    properties: {
        men: Number,
        women: Number,
    },

    /**
     * 组件的初始数据
     */
    data: {
        showSearchTypeStatus: false,
        searchWorkerTypeText: '名称',
        searchWorkerTypeKey: 'workerName',
        searchWorkerType: [
            {
                text: '名称',
                key: 'workerName'
            },
            {
                text: '身份证',
                key: 'idCardNo'
            },
            {
                text: '民族',
                key: 'nation'
            }
        ],
        input: ''
    },

    /**
     * 组件的方法列表
     */
    methods: {
        // 显示切换搜索类型框
        showSearchType() {
            this.setData({
                showSearchTypeStatus: !this.data.showSearchTypeStatus
            })
        },
        // 切换搜索类型
        checkSearchType(event) {
            this.setData({
                showSearchTypeStatus: false
            })
            this.setData({
                'showSearchTypeStatus': false,
                searchWorkerTypeKey: event.currentTarget.dataset.key,
                searchWorkerTypeText: event.currentTarget.dataset.text,
                input: ''
            })
            this.searchWorker({detail:{value: ''}})
        },
        // 输入input框，提交给父页面
        searchWorker(event){
            this.triggerEvent('input',{
                value: event.detail.value,
                key: this.data.searchWorkerTypeKey
            })
        }
    }
})
